package com.servlet;

import com.entity.Working;
import com.service.WorkingService;
import org.apache.ibatis.annotations.Param;
import org.junit.Test;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.List;

@WebServlet(urlPatterns = {"/ListInfo"},name = "ListInfo")
public class ListInfoServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置字符编码集
        request.setCharacterEncoding("UTF-8");
        //设置响应内容类型  
        response.setContentType("text/html;charset=UTF-8");

        WorkingService workingService = new WorkingService();

        List<Working> listInfos = workingService.getListInfos();

       /* for (int i = 0; i < listInfos.size();i++) {
            SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
            date.format(listInfos.get(i).getCreateDate());
        }*/

        HttpSession session = request.getSession();
        //	存值
        request.setAttribute("list", listInfos);

        //	跳转页面
        request.getRequestDispatcher("info.jsp").forward(request, response);

    }


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);
    }
}  

